// 简单数据类型 Number, String, Null, Undefined, Boolean
// 复杂数据类型 Object

console.log("typeof");
function A() {};
let B = function(){};
console.log("function A() {}", typeof A);
console.log("B = function(){}", typeof B);
console.log("Symbol", typeof Symbol);

console.log("[]", typeof []);
console.log("{}", typeof {});
console.log("null", typeof null);

// new 出来的都是 object
console.log("new Array()", typeof new Array());
console.log("new Number(10)", typeof new Number(10));

console.log("-----------");
console.log("instanceof");

let a = new Number(100);
console.log("new Number(100) instanceof Number", a instanceof Number);

let b = new String("Abc");
console.log(`new String("Abc") instanceof Number`, b instanceof String);

let c = new Array(2, 4, 5);
// 精确到了 Array
console.log("new Array(2, 4, 5) instanceof new Array", c instanceof Array);
// 但仍然是Object
console.log("new Array(2, 4, 5) instanceof new Object", c instanceof Object);

// instanceof 的左操作数必须是一个实例，这意味着如果是“基本类型”，它必须经过 new 创建;
console.log("1234 instanceof Number", 1234 instanceof Number);
console.log(`"Hello" instanceof String`, "Hello" instanceof String);

// 而如果是 Object ，则自动创建实例。
console.log(`[1, 3, 5] instanceof Array`, [1, 3, 5] instanceof Array);
console.log(`{name: 'Xmo'} instanceof Object`, {name: 'Xmo'} instanceof Object);